﻿/**
 * 執行初始化
 * 
 * @author LuoDong
 * @email luo4521@online.net.tw
 * 2010-2-3 10:01
 */
package com.addcn.texas.control {
	import com.addcn.fog.control.ICommand;
	import com.addcn.fog.control.SimpleCommand;
	import com.addcn.texas.model.UserInfoModel;
	
	import com.addcn.texas.Main;
	import com.addcn.texas.model.StartupModel;
	import com.addcn.texas.model.HallModel;
	import com.addcn.texas.view.*;	
	import com.addcn.common.utils.DestroyMemory;
	import flash.display.Sprite;
	
	public class StartupCommand extends SimpleCommand implements ICommand {
		
		public override function execute(r_data:Object = null):void {				
			viewLocator.initialize( r_data as Sprite);  //将对象传递给视图定位器	
			viewLocator.addView(LoadingView, Main.loading_container);
			viewLocator.addView(PopupView, Main.popup_container); 
			viewLocator.addView(StartupView);   //默认传递 initialize 所设置的容器给 starupView				
			viewLocator.addView(HallView); //房間列表視圖控制器					
			viewLocator.addView(FriendsView); //好友列表視圖控制							
			modelLocator.addModel(UserInfoModel);
			modelLocator.addModel(HallModel);  
			modelLocator.addModel(StartupModel); 				
			var _model = modelLocator.getModel(StartupModel) as StartupModel;
			_model.connect();					
			
			sendNotification(Main.APP_STARTUP); 
			DestroyMemory.clear();
		}

	}
}
